package com.zhou.common.mybatis.template.shiro.controller;


import com.zhou.common.base.mq.model.ExcelResVo;
import com.zhou.common.base.mq.model.Response;
import com.zhou.common.mybatis.template.shiro.service.impl.ImportStudentServiceImpl;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 导入学生信息 前端控制器
 * </p>
 *
 * @author zcy
 * @since 2022-08-12
 */
@RestController
@RequestMapping("/temp/import-student")
public class ImportStudentController {

    @Autowired
    private ImportStudentServiceImpl studentService;

    /**
     * 从学信网获取学生信息，并检验毕业学校，与导入学校是否一致
     */
    @ApiOperation("回显excel导入内容")
    @PostMapping("/import/preview")
    public Response importPreview(@RequestParam("file") MultipartFile file) throws Exception {
        ExcelResVo resVo = studentService.importPreview(file);
        return Response.success(resVo);
    }

    /**
     * 确定导入Excel内容
     */
    @ApiOperation("存储导入内容")
    @PostMapping("/import/save")
    public Response excelImport(@RequestParam String seriId) {
        studentService.importExcel(seriId);
        return Response.success();
    }
}
